//
//  RegisterView.m
//  Exam14-1
//
//  Created by 孙晓晔 on 2017/5/5.
//  Copyright © 2017年 孙晓晔. All rights reserved.
//

#import "RegisterView.h"

@implementation RegisterView

// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
    
    CGContextRef context = UIGraphicsGetCurrentContext();
    //    CGContextSetLineWidth(context, 1);
    CGContextSetFillColorWithColor(context, [UIColor grayColor].CGColor);
    ////    CGContextAddRect(context, CGRectMake(65, 125, 270, 85));
    //
    //    CGContextAddEllipseInRect(context, CGRectMake(65, 125, 270, 85))
    //    CGContextStrokePath(context);
    
    [self drawRoundRectInContext:context withRect:CGRectMake(45, 125, 275, 85)];
    
    
}


-(void)drawRoundRectInContext:(CGContextRef)context withRect:(CGRect)rect{
    
    CGFloat minx = CGRectGetMinX(rect);
    CGFloat midx = CGRectGetMidX(rect);
    CGFloat maxx = CGRectGetMaxX(rect);
    
    
    CGFloat miny = CGRectGetMinY(rect);
    CGFloat midy = CGRectGetMidY(rect);
    CGFloat maxy = CGRectGetMaxY(rect);
    
    //    CGFloat filletRadius = CGRectGetHeight(rect)/2;
    CGFloat filletRadius = 10;
    
    //    CGContextMoveToPoint(context,150,50);//圆弧的起始点
    //    CGContextAddArcToPoint(context,100,80,130,150,50);
    //    CGContextStrokePath(context);
    
    CGContextMoveToPoint(context, minx, midy);
    
    CGContextAddArcToPoint(context, minx, miny, minx+10, miny, filletRadius);
    
    CGContextAddArcToPoint(context, maxx, miny, maxx, miny+10, filletRadius);
    
    CGContextAddArcToPoint(context, maxx, maxy, maxx-10, maxy, filletRadius);
    
    CGContextAddArcToPoint(context, minx, maxy, minx, maxy-10, filletRadius);
    
    CGContextClosePath(context);
    CGContextSaveGState(context);
    
    CGContextStrokePath(context);
    
    //CGContextFillPath(context);
    
    //CGContextDrawPath(context, kCGPathFillStroke);
    
    CGContextMoveToPoint(context, minx, midy);
    CGContextAddLineToPoint(context, maxx, midy);
    
    CGContextStrokePath(context);
    
    
    
}

@end
